<template>
	<view class="productimg_page">
		 <view class="swiper-container">
			<swiper class="image-container" previous-margin="150rpx" next-margin="150rpx" circular @change="swiperChange">
				<swiper-item :class="currentIndex == index ? 'swiper-item' : 'swiper-item-side'" v-for="(item, index) in imgList" :key="index">
					<text class="uniicons uni_icon" :class="currentIndex == index ? 'item_icon' : 'item_side_icon'">&#xe442;</text>
					<image :class="currentIndex == index ? 'item-img' : 'item-img-side'" :src="item.url" lazy-load :style="dontFirstAnimation ? 'animation: none;' : ''" 
					mode="aspectFit"></image>
				</swiper-item>
			</swiper>
		</view>
		<view class="bottom">
			<view class="content">
				<!-- <view class="btn_wrap">
					<image class="img" mode="aspectFill" src="../../static/image/page/imgDown_01.png"></image>
					<view>分享此海报</view>
				</view> -->
				<view class="btn_wrap"  @click="downImg">
					<image class="img"  mode="aspectFill" src="../../static/image/page/imgDown_02.png"></image>
					<view>下载此海报</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imgList:[],
				currentIndex: 0,
				dontFirstAnimation: true,
			}
		},
		onLoad(option) {
			this.getGeneralizeList(option.id)
		},
		methods: {
			//推广图移动
			swiperChange(e) {
				this.dontFirstAnimation = false
				this.currentIndex = e.detail.current
			},
			//获取推广图图片
			getGeneralizeList(id){
					this.$api.getProList({pageNo:1,pageSize:1000,pid:id}).then(res=> {
					this.imgList = res.data.data.records;
				})
			},
			//下载推广图
			downImg() {
				let index = this.currentIndex;
				let downImgUrl = this.imgList[index].url;
				uni.saveImageToPhotosAlbum({
					filePath: downImgUrl,
					success: function() {
						uni.showToast({
							icon: 'none',
							title: '保存相册成功',
							position:'bottom'
						})
					}
				});
				
			
			
			}
		}
	}
</script>
<style>
	page{background: #F8F8F8;display: flex;justify-content: center;align-items: center;height: calc(100% - 180rpx);box-sizing: border-box;}
</style>
<style scoped lang="scss">
	
	.bottom{width: 100%;height: 180rpx;background: #FFFFFF;position: fixed;bottom: 0;left: 0;}
	.content{width: 750rpx;height: 100%;margin: 0 auto; display: flex;align-items: center;justify-content: space-around;}
	.btn_wrap{text-align: center;}
	.img{width: 76rpx;height: 76rpx;}
	.image-container {width: 750rpx;height: 900rpx;}
	.item-img {width: 100%;height: 900rpx;border-radius: 14rpx;animation: to-big .3s;}
	.swiper-item {width: 100%;height: 900rpx;display: flex;justify-content: center;position: relative;
		align-items: center;padding: 0 20rpx;box-sizing: border-box;}
	.item-img-side {width: 100%;height: 780rpx;border-radius: 14rpx;animation: to-mini .3s;}
	.swiper-item-side {position: relative;width:100%;height: 780rpx;display: flex;justify-content: center;align-items: center;padding: 0 20rpx;box-sizing: border-box;}
	.uni_icon{font-size: 24px;position: absolute;z-index: 999;top: 20rpx;right: 20rpx;}
	.item_icon{color: red;}
	.item_side_icon{top: 60rpx;right: 40rpx;color: #FFFFFF;}
	@keyframes to-mini
	{
		from {
			height: 900rpx;
		}
		to {
			height: 780rpx;
		}
	}
	@keyframes to-big
	{
		from {
			height: 780rpx;
		}
		to {
			height: 900rpx;
		}
	}
</style>

